import type { FullReductionRules } from '@/apis/plugin/fullDiscount/model'

const { divTenThousand } = useConvert()

export function formatFullDiscountRules(rules: FullReductionRules) {
  return rulesHandler[rules.fullReductionRule](rules)
}

//注释
const rulesHandler = {
  // 满减
  FULL_REDUCTION: (rule: FullReductionRules, isConfirmOrder = false) => {
    return `满${divTenThousand(rule.conditionAmount)}减${divTenThousand(isConfirmOrder ? rule.orderDiscount : rule.discountAmount)}`
  },
  // 满折
  FULL_DISCOUNT: (rule: FullReductionRules, isConfirmOrder = false) => {
    return `满${divTenThousand(rule.conditionAmount)}打${rule.discountRatio}折`
  },
}
